package algorithm.quartile;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import util.Constants;

import algorithm.RADDACL_Cluster;
import algorithm.Region;
/**
 * 
 * @author Dan
 *
 */
public abstract class DistanceTable implements Iterable<Distance>
{
	protected List<Distance> distances;
	protected RADDACL_Cluster parent;
	/**
	 * 
	 * @param parent
	 * @param region
	 * @param inputIndexes
	 */
	public DistanceTable(RADDACL_Cluster parent)
	{
		this.distances = new LinkedList<Distance>();
		this.parent = parent;
	}
	@Override
	public Iterator<Distance> iterator()
	{
		return this.distances.iterator();
	}
	/**
	 * 
	 * @return
	 */
	public double getThreshold()
	{
		double q1 = distances.get((int)(distances.size()*.25)).getDistance();
		double q3 = distances.get((int)(distances.size()*.75)).getDistance();
		
		try
		{
			double outliervalue = Double.parseDouble((String)Constants.instance.constants.get("outliervalue"));
			
			return q3 + (outliervalue * (q3 - q1));
		}
		catch(Exception e)
		{
			e.printStackTrace();
			return q3 + (1.5 * (q3 - q1));
		}
	}
	/**
	 * 
	 * @param parent
	 * @param inputIndexes
	 */
	public abstract void generateDistanceTable();
}
